<? include("/inc/header.html") {} ?>
	<div class="page-content" style="margin-top: -15px;">
		<div class="row mbl" style="overflow: auto;height: 100%;">
			<div class="col-lg-12">
				<div class="portlet box">
                    <div class="portlet-body" style="height: 90%;overflow: auto;">
                        <div class="table-responsive">
						<div id="example1_wrapper"
							class="dataTables_wrapper form-inline no-footer">
							<div class="row">
								<div class="col-md-12">
									<div id="example1_filter" class="dataTables_filter">
										<label>
											<div class="input-group input-group-sm mbs">
												<span class="input-group-btn" style="font-size: 12px;">
													课程名称
												</span>
												<input type="text"  class="form-control" id="name" name="name" />
											</div>
										</label>
										<label>
											<div class="input-group input-group-sm mbs">
												<span class="input-group-btn" style="font-size: 12px;">
													所属栏目:
												</span>
												<select class="form-control" id="categoryId" style="width: 170px;">
													<option value="">全部</option>
													<option value="01">语文</option>
													<option value="02">数学</option>
													<option value="02">英语</option>
												</select>
											</div>
										</label>
										<label>
											<div class="input-group input-group-sm mbs">
												<span class="input-group-btn" style="font-size: 12px;">
													标签：
												</span>
												<input type="text"  class="form-control" id="tag" name="tag" />
											</div>
										</label>
										<label>
											<div class="input-group input-group-sm mbs">
												<span class="input-group-btn" style="font-size: 12px;">
													状态：
												</span>
												<select class="form-control" id="status" style="width: 170px;">
													<option value="">全部</option>
													<option value="0">待审核</option>
													<option value="1">审核通过</option>
													<option value="-1">已注销</option>
													<option value="2">上架中</option>
													<option value="3">已下架</option>
												</select>	
											</div>
										</label>
										<label>
											<div class="input-group input-group-sm mbs">
												<span class="input-group-btn" style="font-size: 12px;">
													学段：
												</span>
												<select class="form-control" id="grade" style="width: 170px;">
													<option value="">全部</option>
													<option value="一年级">一年级</option>
													<option value="二年级">二年级</option>
													<option value="三年级">三年级</option>
												</select>	
											</div>
										</label>
										<label>
											<div class="input-group input-group-sm mbs">
												<span class="input-group-btn">
													<button type="button" data-toggle="dropdown" class="btn btn-blue dropdown-toggle" onclick="get()">查询</button>
												</span>
											</div>
										</label>
									</div>
								</div>
							</div>
							<table style="font-size: 15px;" class="table table-striped table-bordered table-hover dataTable no-footer">
								<thead>
									<tr>
										<th> 选择</th>
										<th>序号</th>
										<th>课程名称</th>
										<th>所属栏目</th>
										<th>标签</th>
										<th>授课教师</th>
										<th>状态</th>
									</tr>
								</thead>
								<tbody id="findUser">
								</tbody>
							</table>
							<div id="page2" style="text-align: center; margin-top: 20px;"></div>
						</div>
					</div>
                    </div>
                    </div>
	</div>
	</div>
	</div>
	<!--END CONTENT-->
<script>
	function getQueryString(name) { 
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); 
	var r = window.location.search.substr(1).match(reg); 
	if (r != null) return unescape(r[2]); return null; 
	} 
	var winName=getQueryString("winName");
	var curr;
	$(function() {
		init();
		demo1(1);
	});
	function init(){
		$.ajax({
				type : "post",
				url : "./categoryAllList.do",
				dataType : "json",
				success : function(data) {
					var html = '<option value="">全部</option>';
					for(var i in data){
						html+='<option value="'+data[i].id+'">'+data[i].name+'</option>';
					}
					$("#categoryId").html(html);
				},
				error : function(data) {
					alert("请求失败");
				}
			});
	}
	function demo1(cur) {
		$.getJSON("./courseList.do",
			{
				page : cur || 1,
				name:$("#name").val(),
        		tag:$("#tag").val(),
        		status:$("#status").val(),
        		categoryId:$("#categoryId").val(),
        		grade:$("#grade").val(),
			},
			function(res) {
				//此处仅仅是为了演示变化的内容
				var str = "";
				$("#findUser").html("");
				if(res.listsize>0){
					$("#dataNull").html("");
				}else{
					$("#dataNull").html("<span class='subtitle' style='font-size: 15px;'>数据为空!</span>");
				}
				for ( var i = 0; i < res.listsize; i++) {
					str += "<tr><td>"
							+ '<input name="checkall" type="radio" value="'+res.result[i].id+'" val="'+res.result[i].name+'"/>'
							+ '</td><td>'
							+ (i + 1)
							+ "</td><td> <label>"
							+ res.result[i].name
							+ "</label></td><td><label >"
							+ res.result[i].categoryId
							+ "</label></td><td><label >"
							+ res.result[i].tag
							+ "</label></td><td><label >"
							+ res.result[i].userIds
							+ "</label></td><td><label >";
							if(res.result[i].auditType=='0'){
								str+="注册：";
							}else if(res.result[i].auditType=='1'){
								str+="注销：";
							}else if(res.result[i].auditType=='2'){
								str+="上架：";
							}else if(res.result[i].auditType=='3'){
								str+="下架：";
							}
							if(res.result[i].status=='0'){
								str+='待审核';
							}else if(res.result[i].status=='1'){
								str+='不通过';
							}else if(res.result[i].status=='2'){
								str+='通过';
							}
							str+= "</label></td>"
							+ "</tr>";
				}
				$("#findUser").append(str);

				laypage({
					cont : document.getElementById('page2'), //容器。值支持id名、原生dom对象，jquery对象,
					pages : res.pageSize, //总页数
					skip : true, //是否开启跳页
					skin : 'molv', //加载内置皮肤，也可以直接赋值16进制颜色值，如:#c00
					curr: curr || 1,
					last: res.pageSize,
					groups : 6,//连续显示分页数
					jump : function(obj, first) { //触发分页后的回调
						if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
							demo1(obj.curr);
							 var curr = obj.curr;
			                 curr=obj.curr;
						}
					}
				});
			});
	};
	function save(){
		var id=$("input[name='checkall']:checked").val();
		var name=$("input[name='checkall']:checked").attr("val");
		var index = parent.layer.getFrameIndex(window.name);
		window.parent.window[winName].setCourse(id,name);
		parent.layer.close(index);
	}
</script>